****APPENDIX TABLE E9****

cd "$main_dir/output/tables/appendix_e"

global basic 	marital edu
global econ	    employment_status occupation income imputed_income
global design 	survey_year age language
global polit    ideology party_member

//--------------------------------------------------------
//Define relevant program
//--------------------------------------------------------

capture program drop standardize
program define standardize
	
	args depvar
	
	cap drop z*
	local varlist `depvar' wgrowth_rate_1
	foreach var of local varlist {
		egen z`var' = std(`var') if e(sample)==1
}														

end

//--------------------------------------------------------
//Read in relevant data
//--------------------------------------------------------

clear
use "$data_dir/clean/shp_final_panel.dta"

gen dummy = 1 if trust_fed_govt_med!=.
bys idpers: egen total_obs = total(dummy)

xtset idpers survey_year

cap drop sample
gen sample = 1 if live_switz==1 & total_obs>4 & total_obs!=. & age>=15 & age!=.

egen canton_survey_year = group(canton survey_year)

//--------------------------------------------------------
//Create Table E9 (Panel A)
//--------------------------------------------------------

//Column 1
qui reghdfe trust_fed_govt_med wgrowth_rate_1 if sample==1 [pw = wicss], absorb(canton $basic $design $econ $polit yob) cluster(idhous yob)
standardize trust_fed_govt_med
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if e(sample)==1 [pw = wicss], absorb(canton $basic $design $econ $polit yob) cluster(idhous yob)
outreg2 using table_e9_panel_a.doc, replace dec(3) nocons addtext(Individual FE, No, ///
													            Canton FE, Yes, ///
													            Survey Year FE, Yes, ///
													            Canton FE x Survey Year FE, No) keep(zwgrowth_rate_1) 

//Column 2
qui reghdfe trust_fed_govt_med wgrowth_rate_1 if sample==1 [pw = wicss], absorb(canton_survey_year $basic $design $econ $polit yob) cluster(idhous yob)
standardize trust_fed_govt_med
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if e(sample)==1 [pw = wicss], absorb(canton_survey_year $basic $design $econ $polit yob) cluster(idhous yob)
outreg2 using table_e9_panel_a.doc, append dec(3) nocons addtext(Individual FE, No, ///
													            Canton FE, No, ///
													            Survey Year FE, No, ///
													            Canton FE x Survey Year FE, Yes) keep(zwgrowth_rate_1) 

//Column 3
qui reghdfe trust_others_med wgrowth_rate_1 if sample==1 [pw = wicss], absorb(canton $basic $design $econ $polit yob) cluster(idhous yob)
standardize trust_others_med
reghdfe ztrust_others_med zwgrowth_rate_1 if e(sample)==1 [pw = wicss], absorb(canton $basic $design $econ $polit yob) cluster(idhous yob)
outreg2 using table_e9_panel_a.doc, append dec(3) nocons addtext(Individual FE, No, ///
													            Canton FE, Yes, ///
													            Survey Year FE, Yes, ///
													            Canton FE x Survey Year FE, No) keep(zwgrowth_rate_1) 

//Column 4
qui reghdfe trust_others_med wgrowth_rate_1 if sample==1 [pw = wicss], absorb(canton_survey_year $basic $design $econ $polit yob) cluster(idhous yob)
standardize trust_others_med
reghdfe ztrust_others_med zwgrowth_rate_1 if e(sample)==1 [pw = wicss], absorb(canton_survey_year $basic $design $econ $polit yob) cluster(idhous yob)
outreg2 using table_e9_panel_a.doc, append dec(3) nocons addtext(Individual FE, No, ///
													            Canton FE, No, ///
													            Survey Year FE, No, ///
													            Canton FE x Survey Year FE, Yes) keep(zwgrowth_rate_1) 

//--------------------------------------------------------
//Create Table E9 (Panel B)
//--------------------------------------------------------

//Column 1
qui reghdfe trust_fed_govt_med wgrowth_rate_1 if sample==1 [pw = wicss], absorb(canton $basic $design $econ $polit cohort) cluster(idhous yob)
standardize trust_fed_govt_med
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if e(sample)==1 [pw = wicss], absorb(canton $basic $design $econ $polit cohort) cluster(idhous yob)
outreg2 using table_e9_panel_b.doc, replace dec(3) nocons addtext(Individual FE, No, ///
													            Canton FE, Yes, ///
													            Survey Year FE, Yes, ///
													            Canton FE x Survey Year FE, No) keep(zwgrowth_rate_1) 

//Column 2
qui reghdfe trust_fed_govt_med wgrowth_rate_1 if sample==1 [pw = wicss], absorb(canton_survey_year $basic $design $econ $polit cohort) cluster(idhous yob)
standardize trust_fed_govt_med
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if e(sample)==1 [pw = wicss], absorb(canton_survey_year $basic $design $econ $polit cohort) cluster(idhous yob)
outreg2 using table_e9_panel_b.doc, append dec(3) nocons addtext(Individual FE, No, ///
													            Canton FE, No, ///
													            Survey Year FE, No, ///
													            Canton FE x Survey Year FE, Yes) keep(zwgrowth_rate_1) 

//Column 3
qui reghdfe trust_others_med wgrowth_rate_1 if sample==1 [pw = wicss], absorb(canton $basic $design $econ $polit cohort) cluster(idhous yob)
standardize trust_others_med
reghdfe ztrust_others_med zwgrowth_rate_1 if e(sample)==1 [pw = wicss], absorb(canton $basic $design $econ $polit cohort) cluster(idhous yob)
outreg2 using table_e9_panel_b.doc, append dec(3) nocons addtext(Individual FE, No, ///
													            Canton FE, Yes, ///
													            Survey Year FE, Yes, ///
													            Canton FE x Survey Year FE, No) keep(zwgrowth_rate_1) 

//Column 4
qui reghdfe trust_others_med wgrowth_rate_1 if sample==1 [pw = wicss], absorb(canton_survey_year $basic $design $econ $polit cohort) cluster(idhous yob)
standardize trust_others_med
reghdfe ztrust_others_med zwgrowth_rate_1 if e(sample)==1 [pw = wicss], absorb(canton_survey_year $basic $design $econ $polit cohort) cluster(idhous yob)
outreg2 using table_e9_panel_b.doc, append dec(3) nocons addtext(Individual FE, No, ///
													            Canton FE, No, ///
													            Survey Year FE, No, ///
													            Canton FE x Survey Year FE, Yes) keep(zwgrowth_rate_1) 
																
																
//--------------------------------------------------------
//Create Table E9 (Panel C)
//--------------------------------------------------------

//Column 1
qui reghdfe trust_fed_govt_med wgrowth_rate_1 if sample==1 [pw = wicss], absorb(canton $basic $design $econ $polit generation) cluster(idhous yob)
standardize trust_fed_govt_med
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if e(sample)==1 [pw = wicss], absorb(canton $basic $design $econ $polit generation) cluster(idhous yob)
outreg2 using table_e9_panel_c.doc, replace dec(3) nocons addtext(Individual FE, No, ///
													            Canton FE, Yes, ///
													            Survey Year FE, Yes, ///
													            Canton FE x Survey Year FE, No) keep(zwgrowth_rate_1) 

//Column 2
qui reghdfe trust_fed_govt_med wgrowth_rate_1 if sample==1 [pw = wicss], absorb(canton_survey_year $basic $design $econ $polit generation) cluster(idhous yob)
standardize trust_fed_govt_med
reghdfe ztrust_fed_govt_med zwgrowth_rate_1 if e(sample)==1 [pw = wicss], absorb(canton_survey_year $basic $design $econ $polit generation) cluster(idhous yob)
outreg2 using table_e9_panel_c.doc, append dec(3) nocons addtext(Individual FE, No, ///
													            Canton FE, No, ///
													            Survey Year FE, No, ///
													            Canton FE x Survey Year FE, Yes) keep(zwgrowth_rate_1) 

//Column 3
qui reghdfe trust_others_med wgrowth_rate_1 if sample==1 [pw = wicss], absorb(canton $basic $design $econ $polit generation) cluster(idhous yob)
standardize trust_others_med
reghdfe ztrust_others_med zwgrowth_rate_1 if e(sample)==1 [pw = wicss], absorb(canton $basic $design $econ $polit generation) cluster(idhous yob)
outreg2 using table_e9_panel_c.doc, append dec(3) nocons addtext(Individual FE, No, ///
													            Canton FE, Yes, ///
													            Survey Year FE, Yes, ///
													            Canton FE x Survey Year FE, No) keep(zwgrowth_rate_1) 

//Column 4
qui reghdfe trust_others_med wgrowth_rate_1 if sample==1 [pw = wicss], absorb(canton_survey_year $basic $design $econ $polit generation) cluster(idhous yob)
standardize trust_others_med
reghdfe ztrust_others_med zwgrowth_rate_1 if e(sample)==1 [pw = wicss], absorb(canton_survey_year $basic $design $econ $polit generation) cluster(idhous yob)
outreg2 using table_e9_panel_c.doc, append dec(3) nocons addtext(Individual FE, No, ///
													            Canton FE, No, ///
													            Survey Year FE, No, ///
													            Canton FE x Survey Year FE, Yes) keep(zwgrowth_rate_1) 

